package com.sta.oldman.enums;

import lombok.Getter;

/**
 * @author: LunBoWang
 * @description: TODO
 * @date: 2025/7/21 下午7:23
 * @version: 1.0
 */

@Getter
public enum ExceptionEnum {
    UNUSUAL_STRUGGLE(1,"异常挣扎"),
    NO_PEOPLE_EXCEPTION(2,"无人异常"),
    LESS_FOUR_HOUR_SLEEP(3,"不足4小时睡眠"),
    MORE_THAN_TWELVE_HOUR_SLEEP(4,"超过12小时睡眠"),
    EXCESSIVE_BREATHING(5,"呼吸过高"),
    BREATHING_LOWER_THAN_12(6,"呼吸过低");



    final int code;
    final String des;

    ExceptionEnum(int code, String des) {
        this.code = code;
        this.des = des;
    }
    // 通过code获取枚举实例
    public static ExceptionEnum getByCode(int code) {
        for (ExceptionEnum value : values()) {
            if (value.code == code) {
                return value;
            }
        }
        return null; // 未找到对应code的枚举值
    }

    // 通过code直接获取描述
    public static String getDesByCode(int code) {
        ExceptionEnum exception = getByCode(code);
        return exception != null ? exception.des : null;
    }
}
